package com.angel.kuaidi.json.handler;


import com.angel.kuaidi.entity.WuliuInfo;
import com.angel.kuaidi.entity.WuliuInfoItem;
import com.angel.kuaidi.json.CXJsonNode;

public class WuliuInfoHandler implements BaseHandler {

	@Override
	public Object parseJson(CXJsonNode root) {

		WuliuInfo w = null;
		try {
			w=new WuliuInfo();
			w.com = root.getValue("com");
			w.condition = root.getValue("condition");
			w.ischeck = root.getNumber("ischeck");
			w.message = root.getValue("message");
			w.nu = root.getValue("nu");
			w.state = root.getNumber("state");
			w.status = root.getValue("status");
			w.updatetime = root.getValue("updatetime");

			CXJsonNode arr = root.getArray("data");
			if (arr != null) {
				int len = arr.getArrayLength();
				for (int i = 0; i < len; i++) {
					WuliuInfoItem wii = new WuliuInfoItem();
					CXJsonNode temp = arr.getSubNode(i);
					if (temp != null) {
						wii.time = temp.getValue("time");
						wii.context = temp.getValue("context");
						wii.ftime = temp.getValue("ftime");
					}
					w.infos.add(i, wii);
				}
			}
			return w;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
}
